#!/bin/bash
# using dialog to create a menu
red='\033[1;31m'
#红色
green='\033[1;32m'
#绿色
yellow='\033[1;33m'
#黄色
blue='\033[1;34m'
#蓝色
light_cyan='\033[1;96m'
#淡青色
reset='\033[0m'
#重置颜色
cd
sansjtw=server/server.properties
function JTK1() {
wauo=$(whiptail --title "Minecraft rope" --menu "管理你的Minecraft服务器！该脚本部分参照了夜辰的源码，所以非常感谢夜辰！我们的脚本才得以成功发行！！\n创作:金条k\nQQ:3258918614" 0 50 50 \
"1" "启动服务器" \
"2" "配置服务器" \
"0" "退出" \
3>&1 1>&2 2>&3)
case ${wauo} in
1)cd server
./bedrock_server;;
2)check_JTK;;
0) ;;
esac
}
function sans1() {
SANS=$(whiptail --inputbox "请输入服务器名称" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i "1c server-name=${SANS}" ${sansjtw}
check_JTK
}
function sans2() {
sans=$(whiptail --title "编辑该配置" --menu "请选择游戏模式" 0 50 0 \
"1" "生存" \
"2" "创造" \
"3" "冒险" \
3>&1 1>&2 2>&3)
case ${sans} in
1) sed -i '2c gamemode=survival' ${sansjtw}
check_JTK ;;
2) sed -i '2c gamemode=creative' ${sansjtw}
check_JTK ;;
3) sed -i '2c gamemode=adventure' ${sansjtw}
check_JTK ;;
esac
}
function sans3() {
sans=$(whiptail --title "编辑该配置" --menu "请选择游戏难度" 0 50 0 \
"1" "和平" \
"2" "简单" \
"3" "普通" \
"4" "困难" \
3>&1 1>&2 2>&3)
case ${sans} in
1) sed -i '3c difficulty=peaceful' ${sansjtw} 
check_JTK ;;
2) sed -i '3c difficulty=easy' ${sansjtw} 
check_JTK ;;
3) sed -i '3c difficulty=normal' ${sansjtw} 
check_JTK ;;
4) sed -i '3c difficulty=hard' ${sansjtw} 
check_JTK ;;
esac
}
function sans4() {
sans=$(whiptail --title "编辑该配置" --menu "作弊？" 0 50 0 \
"1" "启用" \
"2" "禁用" \
3>&1 1>&2 2>&3)
case ${sans} in
1)
sed -i '4c allow-cheats=true' ${sansjtw}
check_JTK
;;
2)
sed -i '4c allow-cheats=false' ${sansjtw}
check_JTK
;;
esac
}
function sans5() {
sans=$(whiptail --inputbox "请输入最大玩家数" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i "5c max-players=${sans}" ${sansjtw}
check_JTK
}
function sans6() {
sans=$(whiptail --title "编辑该配置" --menu "请选择是否账号登入验证？" 0 50 0 \
"1" "启用" \
"2" "禁用" \
3>&1 1>&2 2>&3)
case ${sans} in
1)
sed -i '6c online-mode=true' ${sansjtw}
check_JTK
;;
2)
sed -i '6c online-mode=false' ${sansjtw}
check_JTK
;;
esac
}
function sans7() {
sans=$(whiptail --title "编辑该配置" --menu "请选择是否开启白名单" 0 50 0 \
"1" "启用" \
"2" "禁用" \
3>&1 1>&2 2>&3)
case ${sans} in
1)
sed -i '7c white-list=true' ${sansjtw}
check_JTK
;;
2)
sed -i '7c white-list=false' ${sansjtw}
check_JTK
;;
esac
}
function sans8() {
sans=$(whiptail --inputbox "请输入ip v4的端口" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i "8c server-port=${sans}" ${sansjtw}
check_JTK
}
function sans9() {
sans=$(whiptail --inputbox "请输入ip v6端口" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i "9c server-portv6=${sans}" ${sansjtw}
check_JTK
}
function sans10() {
sans=$(whiptail --inputbox "请输入视距" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i "10c view-distance=${sans}" ${sansjtw}
check_JTK
}
function sans11() {
sans=$(whiptail --inputbox "请输入加载距离" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i "11c tick-distance=${sans}" ${sansjtw}
check_JTK
}
function sans12() {
sans=$(whiptail --inputbox "请输入最大线程数" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i "13c max-threads=${sans}" ${sansjtw}
check_JTK
}
function sans13() {
sans=$(whiptail --inputbox "请输入踢出时间" 15 50 --title "编辑配置" 3>&1 1>&2 2>&3)
sed -i "12c player-idle-timeout=${sans}" ${sansjtw}
check_JTK
}
function sans14() {
sans=$(whiptail --inputbox "请输入世界名称" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i "14c level-name=${sans}" ${sansjtw}
check_JTK
}
function sans15() {
sans=$(whiptail --inputbox "请输入服务器地图种子" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i "15c level-seed=${sans}" ${sansjtw}
check_JTK
}
function sans16() {
sans=$(whiptail --title "配置该服务器" --menu "请选择新玩家权限" 0 50 0 \
"1" "访客" \
"2" "成员" \
"3" "管理" \
3>&1 1>&2 2>&3)
case ${sans} in
1)
sed -i '16c default-player-permission-level=visitor' ${sansjtw}
check_JTK
;;
2)
sed -i '16c default-player-permission-level=member' ${sansjtw}
check_JTK
;;
3)
sed -i '16c default-player-permission-level=operator' ${sansjtw}
check_JTK
;;
esac
}
function sans17() {
sans=$(whiptail --title "配置服务器" --menu "请选择是否强制加载资源包" 0 50 0 \
"1" "启用" \
"2" "禁止" \
3>&1 1>&2 2>&3)
case ${sans} in
1)
sed -i '17c texturepack-required=true' ${sansjtw}
check_JTK
;;
2)
sed -i '17c texturepack-required=false' ${sansjtw}
check_JTK
;;
esac
}
function sans18() {
sans=$(whiptail --title "配置服务器" --menu "请选择是否开启日志" 0 50 0 \
"1" "启用" \
"2" "禁用" \
3>&1 1>&2 2>&3)
case ${COTMP} in
1)
sed -i '18c content-log-file-enabled=true' ${sansjtw}
check_JTK
;;
2)
sed -i '18c content-log-file-enabled=false' ${sansjtw}
check_JTK
;;
esac
}
function sans19() {
sans=$(whiptail --inputbox "请输入要压缩的原始网络有效负载的最小大小" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i '19c compression-threshold=${sans}' ${sansjtw}
check_JTK
}
function sans20() {
sans=$(whiptail --title "配置服务器" --menu "请选择是否启用服务端权威性挖掘" 0 50 0 \
"1" "启用" \
"2" "禁用" \
3>&1 1>&2 2>&3)
case ${COTMP} in
1)
sed -i '25c server-authoritative-block-breaking=true' ${sansjtw}
check_JTK
;;
2)
sed -i '25c server-authoritative-block-breaking=false' ${sansjtw}
check_JTK
;;
esac
}

check_JTK() {
way=$(whiptail --title "配置服务器" --menu "请选择你要修改的配置" 0 50 50 \
"1" "保存并返回" \
"2" "服务器名称" \
"3" "新玩家游戏模式" \
"4" "设定世界的难度" \
"5" "使用类似命令的作弊手段" \
"6" "同时在线的最大玩家数" \
"7" "账号登入验证" \
"8" "白名单模式" \
"9" "ipv4端口port" \
"10" "ipv6端口port" \
"11" "最大视距" \
"12" "加载区块的距离" \
"13" "服务端使用的最大线程数" \
"14" "挂机玩家被踢出的时间" \
"15" "世界名称&文件夹名" \
"16" "地图种子" \
"17" "玩家进入时游戏权限" \
"18" "强制客户端加载服务端资源包" \
"19" "错误内容记录到日志文件中" \
"20" "要压缩的原始网络有效负载的最小大小" \
"21" "服务端权威性挖掘" \
3>&1 1>&2 2>&3)
case ${way} in
1) 
JTK1 
;;
2) 
sans1 
;;
3) 
sans2
;;
4) 
sans3 
;;
5) 
sans4
;;
6) 
sans5 
;;
7) 
sans6 
;;
8) 
sans7 
;;
9) 
sans8 
;;
10)
sans9 
;;
11) 
sans10 
;;
12) 
sans11 
;;
13) 
sans12 
;;
14) 
sans13 
;;
15) 
sans14 
;;
16) 
sans15 
;;
17) 
sans16 
;;
18) 
sans17 
;;
19) 
sans18 
;;
20) 
sans19 
;;
21) 
sans20 
;;
esac
}
JTK1
function sans1() {
SANS=$(whiptail --inputbox "请输入服务器名称" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i "1c server-name=${SANS}" ${sansjtw}
check_JTK
}
function sans2() {
sans=$(whiptail --title "编辑该配置" --menu "请选择游戏模式" 0 50 0 \
"1" "生存" \
"2" "创造" \
"3" "冒险" \
3>&1 1>&2 2>&3)
case ${sans} in
1) sed -i '2c gamemode=survival' ${sansjtw}
check_JTK ;;
2) sed -i '2c gamemode=creative' ${sansjtw}
check_JTK ;;
3) sed -i '2c gamemode=adventure' ${sansjtw}
check_JTK ;;
esac
}
function sans3() {
sans=$(whiptail --title "编辑该配置" --menu "请选择游戏难度" 0 50 0 \
"1" "和平" \
"2" "简单" \
"3" "普通" \
"4" "困难" \
3>&1 1>&2 2>&3)
case ${sans} in
1) sed -i '3c difficulty=peaceful' ${sansjtw} 
check_JTK ;;
2) sed -i '3c difficulty=easy' ${sansjtw} 
check_JTK ;;
3) sed -i '3c difficulty=normal' ${sansjtw} 
check_JTK ;;
4) sed -i '3c difficulty=hard' ${sansjtw} 
check_JTK ;;
esac
}
function sans4() {
sans=$(whiptail --title "编辑该配置" --menu "作弊？" 0 50 0 \
"1" "启用" \
"2" "禁用" \
3>&1 1>&2 2>&3)
case ${sans} in
1)
sed -i '4c allow-cheats=true' ${sansjtw}
check_JTK
;;
2)
sed -i '4c allow-cheats=false' ${sansjtw}
check_JTK
;;
esac
}
function sans5() {
sans=$(whiptail --inputbox "请输入最大玩家数" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i "5c max-players=${sans}" ${sansjtw}
check_JTK
}
function sans6() {
sans=$(whiptail --title "编辑该配置" --menu "请选择是否账号登入验证？" 0 50 0 \
"1" "启用" \
"2" "禁用" \
3>&1 1>&2 2>&3)
case ${sans} in
1)
sed -i '6c online-mode=true' ${sansjtw}
check_JTK
;;
2)
sed -i '6c online-mode=false' ${sansjtw}
check_JTK
;;
esac
}
function sans7() {
sans=$(whiptail --title "编辑该配置" --menu "请选择是否开启白名单" 0 50 0 \
"1" "启用" \
"2" "禁用" \
3>&1 1>&2 2>&3)
case ${sans} in
1)
sed -i '7c white-list=true' ${sansjtw}
check_JTK
;;
2)
sed -i '7c white-list=false' ${sansjtw}
check_JTK
;;
esac
}
function sans8() {
sans=$(whiptail --inputbox "请输入ip v4的端口" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i "8c server-port=${sans}" ${sansjtw}
check_JTK
}
function sans9() {
sans=$(whiptail --inputbox "请输入ip v6端口" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i "9c server-portv6=${sans}" ${sansjtw}
check_JTK
}
function sans10() {
sans=$(whiptail --inputbox "请输入视距" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i "10c view-distance=${sans}" ${sansjtw}
check_JTK
}
function sans11() {
sans=$(whiptail --inputbox "请输入加载距离" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i "11c tick-distance=${sans}" ${sansjtw}
check_JTK
}
function sans12() {
sans=$(whiptail --inputbox "请输入最大线程数" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i "13c max-threads=${sans}" ${sansjtw}
check_JTK
}
function sans13() {
sans=$(whiptail --inputbox "请输入踢出时间" 15 50 --title "编辑配置" 3>&1 1>&2 2>&3)
sed -i "12c player-idle-timeout=${sans}" ${sansjtw}
check_JTK
}
function sans14() {
sans=$(whiptail --inputbox "请输入世界名称" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i "14c level-name=${sans}" ${sansjtw}
check_JTK
}
function sans15() {
sans=$(whiptail --inputbox "请输入服务器地图种子" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i "15c level-seed=${sans}" ${sansjtw}
check_JTK
}
function sans16() {
sans=$(whiptail --title "配置该服务器" --menu "请选择新玩家权限" 0 50 0 \
"1" "访客" \
"2" "成员" \
"3" "管理" \
3>&1 1>&2 2>&3)
case ${sans} in
1)
sed -i '16c default-player-permission-level=visitor' ${sansjtw}
check_JTK
;;
2)
sed -i '16c default-player-permission-level=member' ${sansjtw}
check_JTK
;;
3)
sed -i '16c default-player-permission-level=operator' ${sansjtw}
check_JTK
;;
esac
}
function sans17() {
sans=$(whiptail --title "配置服务器" --menu "请选择是否强制加载资源包" 0 50 0 \
"1" "启用" \
"2" "禁止" \
3>&1 1>&2 2>&3)
case ${sans} in
1)
sed -i '17c texturepack-required=true' ${sansjtw}
check_JTK
;;
2)
sed -i '17c texturepack-required=false' ${sansjtw}
check_JTK
;;
esac
}
function sans18() {
sans=$(whiptail --title "配置服务器" --menu "请选择是否开启日志" 0 50 0 \
"1" "启用" \
"2" "禁用" \
3>&1 1>&2 2>&3)
case ${COTMP} in
1)
sed -i '18c content-log-file-enabled=true' ${sansjtw}
check_JTK
;;
2)
sed -i '18c content-log-file-enabled=false' ${sansjtw}
check_JTK
;;
esac
}
function sans19() {
sans=$(whiptail --inputbox "请输入要压缩的原始网络有效负载的最小大小" 15 50 --title "编辑该配置" 3>&1 1>&2 2>&3)
sed -i '19c compression-threshold=${sans}' ${sansjtw}
check_JTK
}
function sans20() {
sans=$(whiptail --title "配置服务器" --menu "请选择是否启用服务端权威性挖掘" 0 50 0 \
"1" "启用" \
"2" "禁用" \
3>&1 1>&2 2>&3)
case ${COTMP} in
1)
sed -i '25c server-authoritative-block-breaking=true' ${sansjtw}
check_JTK
;;
2)
sed -i '25c server-authoritative-block-breaking=false' ${sansjtw}
check_JTK
;;
esac
}